package com.compass.mobile.ui.activity

import AppFrontBack
import AppFrontBackListener
import LogUtil
import android.app.Activity
import android.app.Application
import android.content.Intent
import android.os.Bundle
import androidx.fragment.app.Fragment
import androidx.fragment.app.FragmentTransaction
import com.compass.mobile.R
import com.compass.mobile.databinding.ActivityMainBinding
import com.compass.mobile.framework.base.BaseVBActivity
import com.compass.mobile.framework.constant.KEY_TOKEN
import com.compass.mobile.ui.fragment.HospitalChoiceFragment
import com.iflytek.xiri.app.Feedback
import com.iflytek.xiri.scene.ISceneListener
import com.iflytek.xiri.scene.Scene
import com.iflytek.xiri.scene.SceneInfo
import toJson


/**
 * Description： 首页选择医院
 * Date:2024/5/20 16:20
 */
class MainActivity : BaseVBActivity<ActivityMainBinding>(){

    private lateinit var hospitalChoiceFragment: HospitalChoiceFragment
    override fun initView(savedInstanceState: Bundle?) {
        val token :String? = intent.data?.getQueryParameter("token")
//        hospitalChoiceFragment=HospitalChoiceFragment()
//        val bundle = Bundle()
//        bundle.putString(KEY_TOKEN,token)
//        hospitalChoiceFragment.arguments = bundle
//        displaySelectedFragment(hospitalChoiceFragment)
    }

    //这里临时修改
    override fun initData() {
        //这里后续接收动态的值
        UserInfoManager.clearUserInfo()//每次登录情况一次用户信息
        showLoading()



    }

    /**
     * 注册APP前后台切换监听
     */
    private fun appFrontBackRegister(application: Application) {
        AppFrontBack.register(application, object : AppFrontBackListener {
            override fun onBack(activity: Activity?) {
                LogUtil.d("onBack")
            }

            override fun onFront(activity: Activity?) {
                LogUtil.d("onFront")
            }
        })
    }

    // 根据需要显示或替换Fragment
    private fun displaySelectedFragment(fragment: Fragment) {
        val fragmentTransaction: FragmentTransaction = supportFragmentManager.beginTransaction()
        fragmentTransaction.replace(R.id.fragmentContainer, fragment)
        fragmentTransaction.commit()
    }


    private var mLastClickBackTime: Long = 0 //上次点击back键的时间

//    override fun onBackPressed() {
//        val current = System.currentTimeMillis()
//        if (current - mLastClickBackTime > 2000) {
//            mLastClickBackTime = current
//            showToast(getStringFromResource(R.string.base_app_exit_one_more_press))
//        } else {
//            super.onBackPressed()
//        }
//    }

}